//
//  ExchangeRecordCell.m
//  Ginix
//
//  Created by fzq on 2025/2/17.
//

#import "ExchangeRecordCell.h"

@interface ExchangeRecordCell()
@property (nonatomic,strong) UILabel * timeLabel;
@property (nonatomic,strong) UILabel * nameLabel;
@property (nonatomic,strong) UILabel * infoLabel;
@property (nonatomic,strong) UILabel * priceLabel;
@end

@implementation ExchangeRecordCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self setSubViewLayout];
    }
    return self;
}
-(void)setSubViewLayout{
    
    [self addSubview:self.nameLabel];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15 * FMScaleX);
        make.top.mas_offset(12 * FMScaleX);
    }];
    
    [self addSubview:self.timeLabel];
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLabel.mas_bottom).offset(4 * FMScaleX);
        make.left.equalTo(self.nameLabel);
    }];
    
    [self addSubview:self.priceLabel];
    [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(-15 * FMScaleX);
        make.centerY.equalTo(self.nameLabel);
    }];
   
    [self addSubview:self.infoLabel];
    [_infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.priceLabel);
        make.centerY.equalTo(self.timeLabel);
    }];
   
}

-(void)setInfoModel:(ExchangeListModel *)infoModel{
    
    self.nameLabel.text = infoModel.describe;
    self.timeLabel.text = infoModel.createTime;
    if (infoModel.consumeType == 3) {
        self.infoLabel.text = [NSString stringWithFormat:@"+%@",infoModel.consumeCoinNum];
    }else{
        self.infoLabel.text = [NSString stringWithFormat:@"-%@",infoModel.consumeCoinNum];
    }
}

-(UILabel *)timeLabel{
    
    if(!_timeLabel){
        _timeLabel = [[UILabel alloc]init];
        _timeLabel.font = Regular(13);
        _timeLabel.textColor = RDRGB(0x666666);
    }
    return _timeLabel;
}

-(UILabel *)nameLabel{
    
    if(!_nameLabel){
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = Regular(17);
        _nameLabel.textColor = RDRGB(0x333333);
    }
    return _nameLabel;
}
-(UILabel *)infoLabel{
    
    if(!_infoLabel){
        _infoLabel = [[UILabel alloc]init];
        _infoLabel.font = Regular(13);
        _infoLabel.textColor = RDRGB(0x666666);
    }
    return _infoLabel;
}
-(UILabel *)priceLabel{
    
    if(!_priceLabel){
        _priceLabel = [[UILabel alloc]init];
        _priceLabel.font = Bold(24);
        _priceLabel.textColor = RDRGB(0x429A93);
    }
    return _priceLabel;
}
@end
